<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<title>DOM操作事件</title>
	</head>
	<body>
		<div id="div1" style="width: 100px; height: 100px; background-color: red;"></div>
		
		<input type="button" value="添加事件" onclick="click1()" />

		<script type="text/javascript">
			function click1(){
				var div1=document.getElementById("div1");
				//调用事件属性赋值
				div1.onmouseover=function(){
					this.style.backgroundColor="skyblue";
				}
				div1.onmouseout=function(){
					this.style.backgroundColor="red";
				}
			}
		</script>
	</body>
</html>
